//
//  ViewController.swift
//  05-懒加载
//
//  Created by 李南江 on 15/9/6.
//  Copyright © 2015年 xiaomage. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    // Swift中的懒加载会在第一个访问的时候执行
    // 懒加载其实就是一个提前准备好的的闭包
    lazy var dataList: [String] = {
        print("我懒加载了")
        return ["lnj", "lmj", "why"]
    }()
    
    let demoFunc = {
        () -> [String]
        in
        print("我懒加载了")
        return ["lnj", "lmj", "123"]
    }
    // 注意懒加载一定要用var
    lazy var dataList2: [String] = self.demoFunc()
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        print(dataList)
        print(dataList)
        
        print(demoFunc())
        
        print(dataList2)
        print(dataList2)
    }


}

